package com.youlin.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

@Configuration
public class FluxRouter {

    @Autowired
    private FluxHandler fluxHandler;

    @Bean
    public RouterFunction<ServerResponse> timerRouter() {
        return route(GET("/myTest/guest/time"), req -> fluxHandler.getTime(req))
                .andRoute(GET("/myTest/guest/date"), fluxHandler::getDate);
    }
}
